<style type="text/css">
.control-label{ font-weight:100; min-width:90px; }
.panel-default{ margin:10px 10px 0px 10px; }
</style>
<div class="panel panel-default">
  <div class="panel-heading">客服信息<a class="pull-right mdBtn" href="javascript:void(0)">修改</a></div>
  <div class="panel-body">
  <form class="form-horizontal">
	  <div class="form-group">
	    <label for="kf_account" class="col-sm-1 control-label">客服ID</label>
	    <div class="col-sm-3"> 
			<div class="input-group"> 
		      <input type="text" class="form-control eacc" readonly id="kf_account" name="kf_account" placeholder="客服ID" value="{$kfConf.key}">
		      <div class="input-group-addon eacc">@{$kfConf.suffix}</div>
			  
				<span class="help-block" id="account_show" style="display: none" >{$kf.kf_account}</span>
			  <input type="hidden" id="kf_accountall" name="kf_accountall" value="{$kf.kf_account}" />
		    </div>
	    </div>
		<div class="col-sm-5"> 
			<span id="helpBlock" class="help-block"><a id="showAcc" href="javascript:void(0)">查看完整</a></span>
			
		</div>
	  </div> 
	  <div class="form-group">
	    <label for="kf_nickname" class="col-sm-1 control-label">客服昵称</label>
	    <div class="col-sm-3">
	      <input type="text" class="form-control" name="kf_nickname" id="kf_nickname" placeholder="客服昵称" value="{$kf.kf_nickname}">
	    </div>
	  </div> 

	  <div class="form-group">
	    <label for="kf_wx" class="col-sm-1 control-label">*微信号</label>
	    <div class="col-sm-3">
	      <input type="text" <if condition="$kf.id gt 0">readonly</if> class="form-control" name="kf_wx" id="kf_wx" placeholder="客服微信号" value="{$kf.kf_wx}">
	    </div>
	  </div>
	   <div class="form-group">
	    <label for="kf_password" class="col-sm-1 control-label" >客服服务介绍</label>
	    <div class="col-sm-3">
	      <input type="textarea" class="form-control" name="kf_introduce" id="kf_introduce" placeholder="客服服务介绍" value="{$kf.introduce}" style="width:600px" maxlength="50">
	    </div>
	  </div>
	  
	  
	  <div class="form-group btnbox">
	    <div class="col-md-offset-1 col-sm-10">
		  <a href="javascript:void(0)" class="btn btn-primary doregBtn">保存</a>
		  <a href="javascript:void(0)" class="btn btn-default qxBtn">取消</a>
	  	</div>
	  </div>
	</form>
  </div>
</div>
<div class="panel panel-default">
  <div class="panel-heading">修改登入密码<a class="pull-right mdBtn" href="javascript:void(0)">修改</a></div>
  <div class="panel-body">
  <form class="form-horizontal">

	  <div class="form-group">
	    <label for="kf_wx" class="col-sm-1 control-label">输入新密码</label>
	    <div class="col-sm-3">
	      <input type="password"  class="form-control" name="newpwd" id="newpwd" placeholder="输入新密码" value="">
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="kf_wx" class="col-sm-1 control-label">确认密码</label>
	    <div class="col-sm-3">
	      <input type="password"  class="form-control" name="validation" id="validation" placeholder="确认密码" value="">
	    </div>
	  </div>

	  
	  <div class="form-group btnbox">
	    <div class="col-md-offset-1 col-sm-10">
		  <a href="javascript:void(0)" class="btn btn-primary " id="savepwd">保存</a>
		  <a href="javascript:void(0)" class="btn btn-default qxBtn">取消</a>
	  	</div>
	  </div>
	</form>
  </div>
</div>
<div class="panel panel-default">
  <div class="panel-heading">客服头像<a class="pull-right mdBtn" href="javascript:void(0)">修改</a></div>
  <div class="panel-body"> 
 <form class="form-horizontal"> 
	  <div class="form-group tarControl">
	    <label for="kf_image" class="col-sm-1 control-label">上传头像</label>
	    <div class="col-sm-3">
			<input type="file" class="form-control" id="kf_image" name="kf_image" placeholder="客服ID">
		</div>
	  </div> 
	  <div class="form-group"> 
	    <div class="col-sm-3 col-md-offset-1">
			<img id="viewImg" src="{$kf.kf_headimgurl}" style="width:80px; height:80px;" />
		</div>
	  </div>
	  <div class="form-group btnbox">
	    <div class="col-md-offset-1 col-sm-10">
		  <a href="javascript:void(0)" id="saveImgBtn" class="btn btn-primary">保存</a>
		  <a href="javascript:void(0)" class="btn btn-default qxBtn">取消</a>
	  	</div>
	  </div>
	</form>
  </div>
</div>

<div class="panel panel-default">
  <div class="panel-heading">登陆微信客服系统</div>
  <div class="panel-body">  
	  <div class="form-group">
	    <div class="col-md-offset-1 col-sm-10">
		  <a href="https://mpkf.weixin.qq.com/cgi-bin/kfloginpage" target="_blank" class="btn btn-primary">去登陆</a> 
	  	</div>
	  </div> 
  </div>
</div>

<script language="javascript">
var imgData = '';
$(function(){
	$('.btnbox,.tarControl').hide();
	$('input').attr('disabled',true);
	
	$('#showAcc').click(function(){
		$('.eacc').hide();
		$('#account_show').show();
	});
	
	$('.mdBtn').click(function(){
		$(this).parents('.panel-default').find('input').removeAttr('disabled');
		$(this).parents('.panel-default').find('.btnbox').show();
		$(this).parents('.panel-default').find('.tarControl').show();
	});
	$('#kf_image').change(function(){
		 var f = $('#kf_image')[0].files[0]; 
		 var reader = new FileReader();
		 reader.onload = function(fl){
			$('#viewImg').attr('src',fl.target.result);
			imgData = fl.target.result;
		 } ;
		 reader.readAsDataURL(f); 
	}); 
	$('.qxBtn').click(function(){
		$(this).parents('.panel-default').find('input').attr('disabled',true);
		$(this).parents('.panel-default').find('.btnbox').hide();
		$(this).parents('.panel-default').find('.tarControl').hide();
	});
	$('.doregBtn').click(function(){
	
		var nickname=$('#kf_nickname').val();
	
		var passwordtoo=$('#kf_passwordtoo').val();
		var introduce=$('#kf_introduce').val();
		var kf_wx=$('#kf_wx').val();
		if(nickname==""){
			alert("客服昵称不能为空");
			return false;
		}
	
		if(introduce==""){
			alert("客服服务介绍不能为空");
			return false;
		}
		if(kf_wx==""){
			alert("微信号不能为空");
			return false;
		}
		//	alert("微信号不能修改请确保");
			var parm = {
			'nickname':nickname,	
			'introduce':introduce,
			'kf_wx':kf_wx
			
			};
		var url = '/admin.php/Customer/kf_register';
		$.post(url,parm,function(obj){
			if(obj.s){
				$('.qxBtn').click();
			}else{
				alert(obj.m);
			}
		},'json');
	});
	
	
		$('#savepwd').click(function(){
	
		var newpwd=$('#newpwd').val();
		var validation=$('#validation').val();
		
		if(newpwd==""){
			alert("密码不能为空");
			return false;
		}
	
		if(newpwd!=validation){
			alert("两次密码不一致");
			return false;
		}
	
	
			var parm = {
			'newpwd':newpwd,	
			};
		var url = '/admin.php/Customer/uppwd';
		$.post(url,parm,function(obj){
			if(obj.s){
				alert(obj.info);
				location.href="/admin.php/public/logout.html";
			}else{
				alert(obj.info);
			}
		},'json');
	});
	
	
	
	$('#saveImgBtn').click(function(){
		var _dom = $(this);
		var url = '/admin.php/Customer/kf_setHeadimg';
		var parm = {'imgData':imgData,'kf_account':$('#kf_accountall').val() };
		console.log(parm);
		$.post(url,parm,function(obj){
			if(obj.s){
				$(_dom).parents('.panel-default').find('input').attr('disabled',true);
				$(_dom).parents('.btnbox , .tarControl').hide(); 
			} 
		},'json'); 
	});
});
</script>